# CLI client entry point

from ptcCLI import pkg_info
from ptcCLI.client import *

import os, sys
import argparse


def main(argv = sys.argv):
    prog_name = os.path.basename(argv[0])
    parser = prepare_option(prog_name)
    args = parser.parse_args(argv[1:])

    if args.version:
        info = pkg_info()
        print info.project_name, info.version
        return 0

    # process command-line arguments

    # execute business logic
    client = PTCClient()
    client.login()

    return 0


def prepare_option(prog):
    parser = argparse.ArgumentParser(description = 'Splits and tracks group payments')

    # optional arguments
    parser.add_argument(
        '-v', '--version',
        action = 'store_true',
        default = False,
        help = 'display the version information',
        dest = 'version'
        )

    return parser


# entry point
if __name__ == '__main__':
    main()
